diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-09-29 08:01:53 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-09-29 08:01:53 +0000 |
| commit | c7d37ec3e60c9197abc79738316ddae7c5bf8817 (patch) | |
| tree | 9b045c7b7302d55f43d76565aa4fd5c6dd3a097b /app/[lng]/evcp/(evcp)/(master-data)/consent/page.tsx | |
| parent | 82a2ce067c9b690cdf7775dfb0be94583f51ca29 (diff) | |
(대표님) 그룹라우터로 앱라우터 경로 정리
Diffstat (limited to 'app/[lng]/evcp/(evcp)/(master-data)/consent/page.tsx')
| -rw-r--r-- | app/[lng]/evcp/(evcp)/(master-data)/consent/page.tsx | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/app/[lng]/evcp/(evcp)/(master-data)/consent/page.tsx b/app/[lng]/evcp/(evcp)/(master-data)/consent/page.tsx new file mode 100644 index 00000000..3e06cb0f --- /dev/null +++ b/app/[lng]/evcp/(evcp)/(master-data)/consent/page.tsx @@ -0,0 +1,89 @@ +// app/admin/policies/page.tsx (서버 컴포넌트) +import { Metadata } from 'next' +import { eq, desc } from 'drizzle-orm' +import db from '@/db/db' +import { policyVersions } from '@/db/schema' +import { PolicyPageClient } from '@/components/polices/policy-page-client' + +export const metadata: Metadata = { + title: '정책 관리 | eVCP Admin', + description: '개인정보 처리방침 및 이용약관 관리' +} + +// 정책 데이터 조회 함수 +async function getPoliciesData() { + try { + // 현재 활성 정책들 (모든 locale) + const currentPolicies = await db + .select() + .from(policyVersions) + .where(eq(policyVersions.isCurrent, true)) + .orderBy(policyVersions.policyType, policyVersions.locale) + + // 전체 정책 히스토리 + const allPolicies = await db + .select() + .from(policyVersions) + .orderBy(desc(policyVersions.createdAt)) + + // locale별로 정책 타입별 그룹화 + const policiesByLocaleAndType = { + ko: { + privacy_policy: allPolicies.filter(p => p.policyType === 'privacy_policy' && p.locale === 'ko'), + terms_of_service: allPolicies.filter(p => p.policyType === 'terms_of_service' && p.locale === 'ko') + }, + en: { + privacy_policy: allPolicies.filter(p => p.policyType === 'privacy_policy' && p.locale === 'en'), + terms_of_service: allPolicies.filter(p => p.policyType === 'terms_of_service' && p.locale === 'en') + } + } + + // 현재 정책 맵 (locale별) + const currentPolicyMap = { + ko: {}, + en: {} + } + currentPolicies.forEach(policy => { + currentPolicyMap[policy.locale][policy.policyType] = policy + }) + + return { + currentPolicies: currentPolicyMap, + allPolicies: policiesByLocaleAndType, + stats: { + totalVersions: allPolicies.length, + koVersions: { + privacy: policiesByLocaleAndType.ko.privacy_policy.length, + terms: policiesByLocaleAndType.ko.terms_of_service.length + }, + enVersions: { + privacy: policiesByLocaleAndType.en.privacy_policy.length, + terms: policiesByLocaleAndType.en.terms_of_service.length + }, + lastUpdate: allPolicies[0]?.createdAt || null + } + } + } catch (error) { + console.error('Failed to fetch policies:', error) + return { + currentPolicies: { ko: {}, en: {} }, + allPolicies: { + ko: { privacy_policy: [], terms_of_service: [] }, + en: { privacy_policy: [], terms_of_service: [] } + }, + stats: { + totalVersions: 0, + koVersions: { privacy: 0, terms: 0 }, + enVersions: { privacy: 0, terms: 0 }, + lastUpdate: null + } + } + } +} + + +export default async function PoliciesPage() { + const data = await getPoliciesData() + + return <PolicyPageClient data={data} /> +} |
